#include<bits/stdc++.h>
using namespace std;
int t,n,m,l,v,car[100003][3],p[1000003],sum=0,min_,min_k;
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d%d%d",&n,&m,&l,&v);
        sum=0;
        min_=m;
        min_k=m;
        for(int i=0;i<n;i++)
            scanf("%d%d%d",&car[i][0],&car[i][1],&car[i++][2]);
        for(int i=0;i<m;i++)
            scanf("%d",&p[i]);
        for(int i=0;i<n;i++)
        {
            int k=0;
            for(;k<=m;k++)
            {
                if(p[k]>=car[i][0]) break;
            }
            int j=k;
            if(car[i][2]<0 && car[i][1]>v)
            {
                min_k=min(min_k,k+1);
                while(car[i][1]<=v)
                {
                    car[i][1]=(int)sqrt(pow(car[i][1],2)+2*car[i][2]*(p[j++]-car[i][0]));
                    car[i][0]=p[j];
                }
                sum+=j-k-1;
                min_=min(m-k-1,min_);
            }
            else if(car[i][1]>v)
            {
                min_k=min(min_k,k+1);
                sum+=m-k;
                min_=min(m-k,min_);
            }
            else if(car[i][2]>0)
            {
                while(car[i][1]>v && j<m)
                {
                    car[i][1]=(int)sqrt(pow(car[i][1],2)+2*car[i][2]*(p[j++]-car[i][0]));
                    car[i][0]=p[j];
                }
                if(j<=m)
                {

                    min_k=min(min_k,k+1);
                    sum+=m-j-k+1;
                    min_=min(m-j-k,min_);
                }
            }
        }
        printf("%d %d",sum-1,min_k+min_);
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
